<?php
	class Order_sizes_model extends CI_Model {	        

    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }

    public function insert($data)
    {
        $this->db->insert('order_sizes',$data);
    }

    public function getInfo($cond = false)
    {
        $this->db->select('*');
        $this->db->from('order_sizes');

        if(!empty($cond))
        {
            if(!empty($cond['order_id']))
                $this->db->where('order_id',$cond['order_id']);            
        }

        $query = $this->db->get();

        return $query->result();
    }

    public function getQty($order_id = false, $product_id = false)
    {
        $this->db->select('*');
        $this->db->from('order_sizes');

        $this->db->where('order_id', $order_id);
        $this->db->where('product_id', $product_id);

        $query = $this->db->get();

        $records = $query->result();

        $qty = '';
        foreach ($records as $record) 
        {
            $qty += $record->quantity;
        }
        return $qty;
    }
} 